#!/usr/bin/env python
# -*- encoding: utf-8 -*-
# Project: spd-sxmcc
"""
@author: lyndon
@time Created on 2018/11/21 10:24
@desc
"""

import time

from bs4 import BeautifulSoup
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
from selenium.webdriver.support.wait import WebDriverWait
from pyquery import PyQuery as pyq

url_prefix = 'https://ty.5i5j.com'
params = DesiredCapabilities.PHANTOMJS
params['phantomjs.page.settings.userAgent'] = 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.162 Safari/537.36'

browser = webdriver.PhantomJS(desired_capabilities=params)
# browser = webdriver.Chrome()


def get_detail(url):
    browser.get(url)
    WebDriverWait(browser, 3)
    pagesource = browser.page_source
    py_html = pyq(pagesource, parser='html')
    next_page = py_html('#expense_desc')

    print(type(next_page))
    print(next_page.text())

    bs = BeautifulSoup(next_page.text(), 'html.parser')
    lis = bs.find_all('strong')

    print(lis)

    data = [i.get_text() for i in lis]

    for i in data:
        print(i.encode('utf-8'))

    # print('================================')
    # sss = [x.text() for x in next_page.items()]
    #
    # print(sss)

    #
    # print(next_page.text())
    # print(next_page.attr.href)



if __name__ == '__main__':
    get_detail('https://shop.10086.cn/goods/351_351_1071672_1050877.html')
    # page_index()
